package com.ruoyi.logistic.controller;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.logistic.domain.*;
import com.ruoyi.logistic.domain.vo.*;
import com.ruoyi.logistic.service.NetworkUndertakeCentreAssessmentService;
import com.ruoyi.logistic.service.NetworkUndertakeCentreLevyService;
import com.ruoyi.logistic.service.NetworkUndertakeCentreStorehouseService;
import com.ruoyi.logistic.service.NetworkUndertakeCentreTransferService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/network/undertakeCentre")
@RestController
@Api(tags = "网点财务_承业对账中心")
public class NetworkUndertakeCentreController {
    @Autowired
    private NetworkUndertakeCentreLevyService networkUndertakeCentreLevyService;
    @Autowired
    private NetworkUndertakeCentreTransferService networkUndertakeCentreTransferService;
    @Autowired
    private NetworkUndertakeCentreAssessmentService networkUndertakeCentreAssessmentService;
    @Autowired
    private NetworkUndertakeCentreStorehouseService networkUndertakeCentreStorehouseService;

    @ApiOperation("搜索派费对账明细")
    @PostMapping("/levy/search")
    public R searchLevy(@RequestBody NetworkUndertakeCentreDetailVo vo){
        List<NetworkUndertakeCentreLevyDetail> levyDetailList = networkUndertakeCentreLevyService.search(vo);
        if (levyDetailList == null || levyDetailList.size() == 0){
            return R.fail("暂无数据");
        }else {
            return R.ok(PageInfo.info(levyDetailList));
        }
    }
    @ApiOperation("查询全部派费对账明细")
    @GetMapping("/levy/selectAll")
    public R selectAllLevy(PageDate pageDate){
        List<NetworkUndertakeCentreLevyDetail> levyDetailList = networkUndertakeCentreLevyService.selectAll(pageDate);
        if (levyDetailList == null || levyDetailList.size() == 0){
            return R.fail("暂无数据");
        }else {
            return R.ok(PageInfo.info(levyDetailList));
        }
    }

    @ApiOperation("添加派费对账明细")
    @PostMapping("/levy/insert")
    public R insertLevy(@RequestBody NetworkUndertakeCentreLevyDetail levyDetail){
        Boolean isAdd = networkUndertakeCentreLevyService.insert(levyDetail);
        if (isAdd){
            return R.ok("添加成功");
        }else {
            return R.fail("添加失败");
        }
    }

    @ApiOperation("修改派费对账明细")
    @PostMapping("/levy/update")
    public R updateLevy(@RequestBody NetworkUndertakeCentreLevyDetail levyDetail){
        Boolean isUpdate = networkUndertakeCentreLevyService.update(levyDetail);
        if (isUpdate){
            return R.ok("修改成功");
        }else {
            return R.fail("修改失败");
        }
    }

    @ApiOperation("删除派费对账明细")
    @PostMapping("/levy/delete")
    public R deleteLevy(Integer id){
        Boolean isDelete = networkUndertakeCentreLevyService.deleteById(id);
        if (isDelete){
            return R.ok("删除成功");
        }else {
            return R.fail("删除失败");
        }
    }

    @ApiOperation("汇总派费对账")
    @PostMapping("/levy/collect")
    public R collectLevy(@RequestBody NetworkUndertakeCentreLevyCollectVo vo){
        List<NetworkUndertakeCentreLevyCollect> levyCollectList = networkUndertakeCentreLevyService.collect(vo);
        if (levyCollectList == null || levyCollectList.size() == 0){
            return R.fail("暂无数据");
        }else {
            return R.ok(PageInfo.info(levyCollectList));
        }
    }

    @ApiOperation("搜索中转费对账明细")
    @PostMapping("/transfer/search")
    public R searchTransfer(@RequestBody NetworkUndertakeCentreTransferDetailVo vo){
        List<NetworkUndertakeCentreTransferDetail> transferDetailList = networkUndertakeCentreTransferService.search(vo);
        if (transferDetailList == null || transferDetailList.size() == 0){
            return R.fail("暂无数据");
        }else {
            return R.ok(PageInfo.info(transferDetailList));
        }
    }
    @ApiOperation("查询全部中转费对账明细")
    @GetMapping("/transfer/selectAll")
    public R selectAllTransfer(PageDate pageDate){
        List<NetworkUndertakeCentreTransferDetail> transferDetailList = networkUndertakeCentreTransferService.selectAll(pageDate);
        if (transferDetailList == null || transferDetailList.size() == 0){
            return R.fail("暂无数据");
        }else {
            return R.ok(PageInfo.info(transferDetailList));
        }
    }

    @ApiOperation("添加中转费对账明细")
    @PostMapping("/transfer/insert")
    public R insertTransfer(@RequestBody NetworkUndertakeCentreTransferDetail transferDetail){
        Boolean isAdd = networkUndertakeCentreTransferService.insert(transferDetail);
        if (isAdd){
            return R.ok("添加成功");
        }else {
            return R.fail("添加失败");
        }
    }

    @ApiOperation("修改中转费对账明细")
    @PostMapping("/transfer/update")
    public R updateTransfer(@RequestBody NetworkUndertakeCentreTransferDetail transferDetail){
        Boolean isUpdate = networkUndertakeCentreTransferService.update(transferDetail);
        if (isUpdate){
            return R.ok("修改成功");
        }else {
            return R.fail("修改失败");
        }
    }

    @ApiOperation("删除中转费对账明细")
    @PostMapping("/transfer/delete")
    public R deleteTransfer(Integer id){
        Boolean isDelete = networkUndertakeCentreTransferService.deleteById(id);
        if (isDelete){
            return R.ok("删除成功");
        }else {
            return R.fail("删除失败");
        }
    }
    @ApiOperation("汇总中转费对账")
    @PostMapping("/transfer/collect")
    public R collectTransfer(@RequestBody NetworkUndertakeCentreTransferCollectVo vo){
        List<NetworkUndertakeCentreTransferCollect> transferCollectList = networkUndertakeCentreTransferService.transferCollect(vo);
        if (transferCollectList == null || transferCollectList.size() == 0){
            return R.fail("暂无数据");
        }else {
            return R.ok(PageInfo.info(transferCollectList));
        }
    }

    @ApiOperation("搜索考核款明细")
    @PostMapping("/assessment/search")
    public R searchAssessment(@RequestBody NetworkUndertakeCentreAssessmentDetailVo vo){
        List<NetworkUndertakeCentreAssessmentDetail> assessmentDetailList = networkUndertakeCentreAssessmentService.search(vo);
        if (assessmentDetailList == null || assessmentDetailList.size() == 0){
            return R.fail("暂无数据");
        }else {
            return R.ok(PageInfo.info(assessmentDetailList));
        }
    }
    @ApiOperation("查询全部考核款明细")
    @GetMapping("/assessment/selectAll")
    public R selectAllAssessment(PageDate pageDate){
        List<NetworkUndertakeCentreAssessmentDetail> assessmentDetailList = networkUndertakeCentreAssessmentService.selectAll(pageDate);
        if (assessmentDetailList == null || assessmentDetailList.size() == 0){
            return R.fail("暂无数据");
        }else {
            return R.ok(PageInfo.info(assessmentDetailList));
        }
    }

    @ApiOperation("添加考核款明细")
    @PostMapping("/assessment/insert")
    public R insertAssessment(@RequestBody NetworkUndertakeCentreAssessmentDetail assessmentDetail){
        Boolean isAdd = networkUndertakeCentreAssessmentService.insert(assessmentDetail);
        if (isAdd){
            return R.ok("添加成功");
        }else {
            return R.fail("添加失败");
        }
    }

    @ApiOperation("修改考核款明细")
    @PostMapping("/assessment/update")
    public R updateAssessment(@RequestBody NetworkUndertakeCentreAssessmentDetail assessmentDetail){
        Boolean isUpdate = networkUndertakeCentreAssessmentService.update(assessmentDetail);
        if (isUpdate){
            return R.ok("修改成功");
        }else {
            return R.fail("修改失败");
        }
    }

    @ApiOperation("删除考核款明细")
    @PostMapping("/assessment/delete")
    public R deleteAssessment(Integer id){
        Boolean isDelete = networkUndertakeCentreAssessmentService.deleteById(id);
        if (isDelete){
            return R.ok("删除成功");
        }else {
            return R.fail("删除失败");
        }
    }
    @ApiOperation("汇总中考核款")
    @PostMapping("/assessment/collect")
    public R collectAssessment(@RequestBody NetworkUndertakeCentreAssessmentCollectVo vo){
        List<NetworkUndertakeCentreAssessmentCollect> assessmentCollects = networkUndertakeCentreAssessmentService.assessmentCollect(vo);
        if (assessmentCollects == null || assessmentCollects.size() == 0){
            return R.fail("暂无数据");
        }else {
            return R.ok(PageInfo.info(assessmentCollects));
        }
    }





    @ApiOperation("搜索包仓费明细")
    @PostMapping("/storehouse/search")
    public R searchStorehouse(@RequestBody NetworkUndertakeCentreStorehouseDetailVo vo){
        List<NetworkUndertakeCentreStorehouseDetail> storehouseDetails = networkUndertakeCentreStorehouseService.search(vo);
        if (storehouseDetails == null || storehouseDetails.size() == 0){
            return R.fail("暂无数据");
        }else {
            return R.ok(PageInfo.info(storehouseDetails));
        }
    }
    @ApiOperation("查询全部包仓费明细")
    @GetMapping("/storehouse/selectAll")
    public R selectAllStorehouse(PageDate pageDate){
        List<NetworkUndertakeCentreStorehouseDetail> storehouseDetails = networkUndertakeCentreStorehouseService.selectAll(pageDate);
        if (storehouseDetails == null || storehouseDetails.size() == 0){
            return R.fail("暂无数据");
        }else {
            return R.ok(PageInfo.info(storehouseDetails));
        }
    }

    @ApiOperation("添加包仓费明细")
    @PostMapping("/storehouse/insert")
    public R insertStorehouse(@RequestBody NetworkUndertakeCentreStorehouseDetail storehouseDetail){
        Boolean isAdd = networkUndertakeCentreStorehouseService.insert(storehouseDetail);
        if (isAdd){
            return R.ok("添加成功");
        }else {
            return R.fail("添加失败");
        }
    }

    @ApiOperation("修改包仓费明细")
    @PostMapping("/storehouse/update")
    public R updateStorehouse(@RequestBody NetworkUndertakeCentreStorehouseDetail storehouseDetail){
        Boolean isUpdate = networkUndertakeCentreStorehouseService.update(storehouseDetail);
        if (isUpdate){
            return R.ok("修改成功");
        }else {
            return R.fail("修改失败");
        }
    }

    @ApiOperation("删除包仓费明细")
    @PostMapping("/storehouse/delete")
    public R deleteStorehouse(Integer id){
        Boolean isDelete = networkUndertakeCentreStorehouseService.deleteById(id);
        if (isDelete){
            return R.ok("删除成功");
        }else {
            return R.fail("删除失败");
        }
    }
    @ApiOperation("汇总包仓费")
    @PostMapping("/storehouse/collect")
    public R collectStorehouse(@RequestBody NetworkUndertakeCentreStorehouseCollectVo vo){
        List<NetworkUndertakeCentreStorehouseCollect> storehouseCollects = networkUndertakeCentreStorehouseService.storehouseCollect(vo);
        if (storehouseCollects == null || storehouseCollects.size() == 0){
            return R.fail("暂无数据");
        }else {
            return R.ok(PageInfo.info(storehouseCollects));
        }
    }
    @ApiOperation("汇总总览")
    @PostMapping("/overview")
    public R overview(@RequestBody NetworkUndertakeCentreOverviewVo vo){
        List<NetworkUndertakeCentreOverview> overviews = networkUndertakeCentreStorehouseService.overview(vo);
        if (overviews == null || overviews.size() == 0){
            return R.fail("暂无数据");
        }else {
            return R.ok(PageInfo.info(overviews));
        }
    }

}
